//
//  UIColor+GradualChanging.m
//  GodCoin
//
//  Created by Bishen on 2018/8/9.
//  Copyright © 2018年 xiaohan. All rights reserved.
//

#import "UIColor+GradualChanging.h"

@implementation UIColor (GradualChanging)
+ (CAGradientLayer *)setGradualChangingFrame:(CGRect)frame fromColor:(UIColor *)fromHexColor toColor:(UIColor *)toHexColor{
    
    //    CAGradientLayer类对其绘制渐变背景颜色、填充层的形状(包括圆角)
    CAGradientLayer *gradientLayer = [CAGradientLayer layer];
    gradientLayer.frame = frame;
    
    //  创建渐变色数组，需要转换为CGColor颜色
    
    gradientLayer.colors = @[(__bridge id)fromHexColor.CGColor,(__bridge id)toHexColor.CGColor];
    
    //  设置渐变颜色方向，左上点为(0,0), 右下点为(1,1)
    gradientLayer.startPoint = CGPointMake(0, 0);
    gradientLayer.endPoint = CGPointMake(1, 0);
    
    //  设置颜色变化点，取值范围 0.0~1.0
    gradientLayer.locations = @[@0,@1];
    
    return gradientLayer;
}

@end
